<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var grid_ae = null;
	var dialog_ae = null;
	$(function(){
		grid_ae = $("#hotel_grid").ligerGrid({
				checkbox: true,
				title : '酒店列表',
                columns: [
                { display: '酒店id', name: 'id', isSort : false, width: 120 },
                { display: '名称', name: 'name',isSort : false, width: 200 },
                { display: '类型', name: 'hotelType',isSort : false, width: 200 },
                { display: '电话', name: 'phone',isSort : false, width: 200 },
                { display: '最低价', name: 'minPrice',isSort : false, width: 200 },
                { display: '最后修改时间', name: 'gmtModified',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }
                },
                {
                	display: '<a href="javascript:;" onclick="addHotel()">新增酒店</a>', 
                	name: 'id',
                	isAllowHide: false, 
                	isSort : false,
					render: function (record, rowindex, value, column){
						var html = '<a onclick="room(\''+ value + '\')" href="javascript:;">房型</a>&nbsp;<a onclick="editHotel(\''+ value + '\')" href="javascript:;">编辑</a>&nbsp;<a onclick="deleteHotel(\''+ value + '\')" href="javascript:;">删除</a>&nbsp;<a target="_blank" href="/hotel.htm?id='+record.id+'">预览</a>'; 
						return html; 
					}
                }
                ], 
                pageSize:10,
                root :'list',
                record:'totalRecord',
                url: "/misc/hotel/hotelGrid.htm", 
                width: '99%',height:'99%',
                isChecked: f_isChecked, onCheckRow: f_onCheckRow, onCheckAllRow: f_onCheckAllRow
            });

		$("#parent").ligerComboBox({
			width : 215,
			selectBoxWidth : 215,
			selectBoxHeight : 180,
			valueField : 'mark',
			textField : 'text',
			treeLeafOnly : false,
			tree : {
				checkbox : false,
				btnClickToToggleOnly : false,
				url : '/misc/cms/channelTree.htm'
			}
		});	
			
	});
	
	function deleteHotel(hotelId){
		$.ligerDialog.confirm('你真的要删除吗？', 
			function (yes){
				if(yes){
					$.post("/misc/hotel/deleteHotel.htm",{hotelId:hotelId}); 
					grid_ae.loadData();
				}
			});
	}
	
	function editHotel(id){
		dialog_ae = $.ligerDialog.open({ height: 500,width:900, url: "/misc/hotel/editHotel.htm?id="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:'编辑酒店'});
	}
	
	function addHotel(){
		dialog_ae = $.ligerDialog.open({ height: 500,width:900, url: "/misc/hotel/addHotel.htm", showMax:true,showMin:true,isResize:true,isDrag:false,title:'新增酒店'});
	
	}
	
	function room(id){
		dialog_ae = $.ligerDialog.open({ height: 500,width:950, url: "/misc/hotel/room.htm?hotelId="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:id+'酒店房型'});
	}
	
	function roomPrice(id){
		dialog_ae = $.ligerDialog.open({ height: 500,width:920, url: "/misc/hotel/roomPrice.htm?hotelId="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:'特价房	'});
	}	
	
	function search(){
		grid_ae.options.parms = [{name:'name',value:$("#search_name").val()}];
		grid_ae.loadData();
	}
	
</script>
<table>
	<tr>
		<td>
			<div id="searchbar">
			   酒店名称：<input id="search_name" type="text" value="${name}"/>
			    <input id="btnOK" type="button" value="查询" onclick="search()" />
			</div>
		</td>
		<td><input type="text" id="parent"/><button onclick="pushHotel()" id="tui_song" style="position:relative;left:220px;top:-22px; margin:0 0 -20px 0;">推送</button></td>
	</tr>
</table>
<div id="hotel_grid" style="margin:0; padding:0"></div>
